package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("business/merchant")
public @caption("品牌信息") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("merchant") class Merchant implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
		
	
		
	private @caption("编号") @column("id")    @primary  @notnull  @note("  ") Long id;// 主键 非空     
			
 			
 			
 		
	
		
	private @caption("品牌名称") @column("brand_name")     @notnull  @note("  ") String brandName;// 非空     
			
 			
 			
 		
	
		
	private @caption("品牌主图") @column("banner")     @notnull  @note("  ") String banner;// 非空     
			
 			
 			
 		
	
		
	private @caption("品牌简介") @column("profile") @like  @hidden    @note("  ") String profile;//     
			
 			
 			
 		
	
		
	private @caption("公司名称") @column("corporate_name")     @notnull  @note("  ") String corporateName;// 非空     
			
 			
 			
 		
	
		
	private @caption("公司地址") @column("company_address") @like    @notnull  @note("  ") String companyAddress;// 非空     
			
 			
 			
 		
	
		
	private @caption("联系人") @column("contacts")     @notnull  @note("  ") String contacts;// 非空     
			
 			
 			
 		
	
		
	private @caption("联系电话") @column("contact_number")     @notnull  @note("  ") String contactNumber;// 非空     
			
 			
 			
 		
	
		
	private @caption("备注信息") @column("remark") @like     @note("  ") String remark;//     
			
 			
 			
 		
	
		
	private @caption("排序") @column("m_sort")      @note("  数值越大越排前") Integer mSort;//  数值越大越排前   
			
 			
 			
 		
	
		
	private @caption("开启状态") @column("open_state")      @note(" 1:关闭 2:开启  ") Short openState;// 1:关闭 2:开启     
			
 			
 			
 		
	
		
	private @caption("修改时间") @column("update_time")     @notnull  @note("  ") Date updateTime;// 非空     
			
 			
 			
 		
	
		
	private @caption("添加时间") @column("add_time")     @notnull  @note("  ") Date addTime;// 非空     
			
 			
 			
 		
	
		
	private @caption("状态") @column("status")     @notnull  @note(" 1:正常 0:无效  ") Short status;// 非空 1:正常 0:无效     
			
 			
 			
 		
	
	 
	//默认构造函数
	public Merchant(){ 
	
	}
	
	//主键构造函数
	public Merchant(Long id){
		this.id = id;
	}
	
	/**所有字段构造函数 
	 Merchant(
	 	Utils.getString("name")//品牌名称 [非空]
	 	,Utils.getString("")//品牌主图 [非空]
	 	,Utils.getString("")//品牌简介
	 	,Utils.getString("name")//公司名称 [非空]
	 	,Utils.getString("address")//公司地址 [非空]
	 	,Utils.getString("")//联系人 [非空]
	 	,Utils.getString("number")//联系电话 [非空]
	 	,Utils.getString("")//备注信息
	 	,Utils.getInteger("sort")//排序
	 	,Utils.getShort("state")//开启状态
	 	,Utils.getDate("time")//修改时间 [非空]
	 	,Utils.getDate("time")//添加时间 [非空]
	 	,Utils.getShort("")//状态 [非空]
	 )
	**/
	public Merchant(String brandName,String banner,String profile,String corporateName,String companyAddress,String contacts,String contactNumber,String remark,Integer mSort,Short openState,Date updateTime,Date addTime,Short status){
		
			
			
		this.brandName=brandName;
		
			
		this.banner=banner;
		
			
		this.profile=profile;
		
			
		this.corporateName=corporateName;
		
			
		this.companyAddress=companyAddress;
		
			
		this.contacts=contacts;
		
			
		this.contactNumber=contactNumber;
		
			
		this.remark=remark;
		
			
		this.mSort=mSort;
		
			
		this.openState=openState;
		
			
		this.updateTime=updateTime;
		
			
		this.addTime=addTime;
		
			
		this.status=status;
		
	}
	
	//设置非空字段
	public Merchant setNotNull(String brandName,String banner,String corporateName,String companyAddress,String contacts,String contactNumber,Date updateTime,Date addTime,Short status){
		
			
			
		this.brandName=brandName;
		
			
		this.banner=banner;
		
			
			
		this.corporateName=corporateName;
		
			
		this.companyAddress=companyAddress;
		
			
		this.contacts=contacts;
		
			
		this.contactNumber=contactNumber;
		
			
			
			
			
		this.updateTime=updateTime;
		
			
		this.addTime=addTime;
		
			
		this.status=status;
		
		return this;
	}
	
	
		
	/** 编号 [非空]       **/
	public Merchant id(Long id){
		this.id = id;
		this.setSeted(F.id);
		return this;
	}
	
		
	/** 品牌名称 [非空]       **/
	public Merchant brandName(String brandName){
		this.brandName = brandName;
		this.setSeted(F.brandName);
		return this;
	}
	
		
	/** 品牌主图 [非空]       **/
	public Merchant banner(String banner){
		this.banner = banner;
		this.setSeted(F.banner);
		return this;
	}
	
		
	/** 品牌简介        **/
	public Merchant profile(String profile){
		this.profile = profile;
		this.setSeted(F.profile);
		return this;
	}
	
		
	/** 公司名称 [非空]       **/
	public Merchant corporateName(String corporateName){
		this.corporateName = corporateName;
		this.setSeted(F.corporateName);
		return this;
	}
	
		
	/** 公司地址 [非空]       **/
	public Merchant companyAddress(String companyAddress){
		this.companyAddress = companyAddress;
		this.setSeted(F.companyAddress);
		return this;
	}
	
		
	/** 联系人 [非空]       **/
	public Merchant contacts(String contacts){
		this.contacts = contacts;
		this.setSeted(F.contacts);
		return this;
	}
	
		
	/** 联系电话 [非空]       **/
	public Merchant contactNumber(String contactNumber){
		this.contactNumber = contactNumber;
		this.setSeted(F.contactNumber);
		return this;
	}
	
		
	/** 备注信息        **/
	public Merchant remark(String remark){
		this.remark = remark;
		this.setSeted(F.remark);
		return this;
	}
	
		
	/** 排序     数值越大越排前   **/
	public Merchant mSort(Integer mSort){
		this.mSort = mSort;
		this.setSeted(F.mSort);
		return this;
	}
	
		
	/** 开启状态    1:关闭 2:开启     **/
	public Merchant openState(Short openState){
		this.openState = openState;
		this.setSeted(F.openState);
		return this;
	}
	
		
	/** 修改时间 [非空]       **/
	public Merchant updateTime(Date updateTime){
		this.updateTime = updateTime;
		this.setSeted(F.updateTime);
		return this;
	}
	
		
	/** 添加时间 [非空]       **/
	public Merchant addTime(Date addTime){
		this.addTime = addTime;
		this.setSeted(F.addTime);
		return this;
	}
	
		
	/** 状态 [非空]   1:正常 0:无效     **/
	public Merchant status(Short status){
		this.status = status;
		this.setSeted(F.status);
		return this;
	}
	
	
	
	/**
	* 克隆对象
	**/
	public Merchant clone(){
		Merchant clone = new Merchant();
		
			
			
		clone.brandName=this.brandName;
		
			
		clone.banner=this.banner;
		
			
		clone.profile=this.profile;
		
			
		clone.corporateName=this.corporateName;
		
			
		clone.companyAddress=this.companyAddress;
		
			
		clone.contacts=this.contacts;
		
			
		clone.contactNumber=this.contactNumber;
		
			
		clone.remark=this.remark;
		
			
		clone.mSort=this.mSort;
		
			
		clone.openState=this.openState;
		
			
		clone.updateTime=this.updateTime;
		
			
		clone.addTime=this.addTime;
		
			
		clone.status=this.status;
		
		return clone;
	}
	
	
	
	/**
	* 清除缓存
	**/
	public void clear(){
		Cache.clearObject(Merchant.M.class);
		Cache.clearValue(Merchant.M.class);
		Cache.deleteObject(Merchant.class, this.getId());
	}
	
	/**
	* 清除缓存
	**/
	public static void clear(Long id){
		Cache.clearObject(Merchant.M.class);
		Cache.clearValue(Merchant.M.class);
		Cache.deleteObject(Merchant.class, id);
	}
	
	
	
	/**
	 * 根据ID取品牌信息
	 * @param id
	 * @return
	 */
	public static @api Merchant get(Long id){		
		return getMerchantById(id);
	}
	
	
	
	/**
	 * 获取所有品牌信息
	 * @return
	 */
	public static @api List<Merchant> list(Map params,Integer size){
		return getMerchantList(params,size);
	}
	/**
	 * 获取品牌信息分页
	 * @return
	 */
	public static @api Page<Merchant> page(Integer page,Integer size,Map params){
		return getMerchantPage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取品牌信息
	 * @param params
	 * @return
	 */
	public static @api Merchant Get(Map params){
		return getMerchant(params);
	}
	/**
	 * 获取品牌信息数
	 * @return
	 */
	public static @api Long count(Map params){
		return getMerchantCount(params);
	}
	/**
	 * 获取品牌信息数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getMerchantEval(eval,params);
	}
	
	
	/**
	 * 获取品牌信息图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getMerchantStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取品牌信息图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getMerchantStats(params,sumKey,groupKey,dateType);
	}
	
	
	/**
	 * 根据ID取品牌信息
	 * @param id
	 * @return
	 */
	public static @api Merchant getMerchantById(Long id){		
		return getMerchantDao().getMerchantById(id);
	}
	
	
	
	
	/**
	 * 根据ID取品牌信息的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			
			return null;
			
		}
		String value = null;
		
		value = Cache.getValue(Merchant.class, id);
				
		if(value==null){
			Merchant merchant = get(id);
			if(merchant!=null){
				String strValue = merchant.getBrandName$();
				
				if(!"BrandName".equals("BrandName"))
					strValue+="("+merchant.getBrandName$()+")";
				
				
				Cache.setValue(Merchant.class, id ,strValue);
				
				value = strValue;
			}else{
				
				Cache.setValue(Merchant.class, id ,"{"+id+"}",30);
				
				value = "{"+id+"}";
			}
		}
		
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getBrandName$();
		
		if(!"BrandName".equals("BrandName"))
			keyValue+="("+this.getBrandName$()+")";
		
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询品牌信息对象
	 * @return
	 */
	public static @api Merchant find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("id", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			
			strDefinex+=" or brand_name = '"+key.replaceAll("'", "''")+"'";
			
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return Merchant.getMerchant(params);
	}
	
	
	/**
	 * 根据关键字查询品牌信息
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("id", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				
				strDefinex+=" or brand_name like '%"+strTerm.replaceAll("'", "''")+"%'";
				
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		
		
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<Merchant> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(Merchant merchant:list){
			Map map = new HashMap();
			map.put("key",merchant.getId().toString());
			map.put("value", Utils.js(merchant.getKeyValue()));
			if(bObject==true)
				map.put("object",merchant);
			result.add(map);
		}
		
		
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有品牌信息
	 * @return
	 */
	public static @api List<Merchant> getMerchantList(Map params,Integer size){
		return getMerchantDao().getMerchantList(params,0,size);
	}
	
	/**
	 * 获取品牌信息分页
	 * @return
	 */
	public static @api Page<Merchant> getMerchantPage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getMerchantDao().getMerchantPage(page, size , params);
	}
	
	/**
	 * 根据查询条件取品牌信息
	 * @param params
	 * @return
	 */
	public static @api Merchant getMerchant(Map params){
		return getMerchantDao().getMerchant(params);
	}
	
	/**
	 * 保存一个品牌信息
	 * @param merchant
	 * @return
	 */
	public static @api Merchant saveMerchant(Merchant merchant){
		return getMerchantDao().saveMerchant(merchant);
	}
	
	/**
	 * 根据条件更新品牌信息
	 * @param values
	 * @param params
	 */
	public static @api int updateMerchantByConfirm(Map values, Map params){
		return getMerchantDao().updateMerchantByConfirm(values,params);
	}
	
	/**
	 * 修改一个品牌信息
	 * @param merchant
	 * @return
	 */
	public static @api int updateMerchant(Merchant merchant){
		return getMerchantDao().updateMerchant(merchant);
	}
	
	/**
	 * 更新品牌信息非空字段
	 * @param merchant
	 */
	public static @api int updateMerchant$NotNull(Merchant merchant){
		return getMerchantDao().updateMerchant$NotNull(merchant);
	}
	
	/**
	 * 获取品牌信息数
	 * @return
	 */
	public static @api Long getMerchantCount(Map params){
		return getMerchantDao().getMerchantCount(params);
	}
		
		
	/**
	 * 获取品牌信息自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getMerchantEval(String eval,Map params){
		return getMerchantDao().getMerchantEval(eval,params);
	}
	
	
	/**
	 * 获取品牌信息图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getMerchantStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getMerchantDao().getMerchantStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = Merchant.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(Merchant.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateMerchant(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getMerchantDao().updateMerchantByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteMerchant(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getMerchantDao().deleteMerchantByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		
		getMerchantDao().removeMerchantById(id);
		
	}
	
	
	/**
	 * 保存品牌信息对象
	 * @param params
	 * @return
	 */
	public Merchant save(){
		if(this.getId()!=null)
			getMerchantDao().updateMerchant(this);
		else
			return getMerchantDao().saveMerchant(this);
		return this;
	}
	
	
	/**
	 * 更新品牌信息对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getMerchantDao().updateMerchant$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
		
		if(Utils.equals(Utils.config("logic_delete"),"true"))
			getMerchantDao().removeMerchantById(this.getId());
		else
		
			getMerchantDao().deleteMerchantById(this.getId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getMerchantDao().executeTransaction(function);
	}

	
	
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getId(){
		
		if(this.id!=null){
			return this.id;
		}
		
		return this.id;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getId$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getId());
	 
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setId$(String strValue){
		if(Utils.empty(strValue)){
			this.id=null;
			return;
		}
	
	
	 	this.id=Utils.parseLong(strValue);
	 
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setId(Long id){
		this.id = id;
		
		this.setSeted(F.id);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************品牌名称**********************************/	
	/**
	* 品牌名称 [非空]      
	**/
	public String getBrandName(){
		
		if(this.brandName!=null){
			return this.brandName;
		}
		
		return this.brandName;
	}
	/**
	* 获取品牌名称格式化(toString)
	**/
	public String getBrandName$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getBrandName());
	 
	 	 return strValue;
	}
	/**
	* 根据品牌名称反格式化
	**/
	public void setBrandName$(String strValue){
		if(Utils.empty(strValue)){
			this.brandName=null;
			return;
		}
	
	
	 	this.brandName=strValue;
	 
	}
	
	/**
	* 品牌名称 [非空]      
	**/
	public void setBrandName(String brandName){
		this.brandName = brandName;
		
		this.setSeted(F.brandName);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************品牌主图**********************************/	
	/**
	* 品牌主图 [非空]      
	**/
	public String getBanner(){
		
		if(this.banner!=null){
			return this.banner;
		}
		
		return this.banner;
	}
	/**
	* 获取品牌主图格式化(toString)
	**/
	public String getBanner$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getBanner());
	 
	 	 return strValue;
	}
	/**
	* 根据品牌主图反格式化
	**/
	public void setBanner$(String strValue){
		if(Utils.empty(strValue)){
			this.banner=null;
			return;
		}
	
	
		this.banner=Utils.parseString(strValue);
	 
	}
	
	/**
	* 品牌主图 [非空]      
	**/
	public void setBanner(String banner){
		this.banner = banner;
		
		this.setSeted(F.banner);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************品牌简介**********************************/	
	/**
	* 品牌简介       
	**/
	public String getProfile(){
		
		if(this.profile!=null){
			return this.profile;
		}
		
		return this.profile;
	}
	/**
	* 获取品牌简介格式化(toString)
	**/
	public String getProfile$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getProfile());
	 
	 	 return strValue;
	}
	/**
	* 根据品牌简介反格式化
	**/
	public void setProfile$(String strValue){
		if(Utils.empty(strValue)){
			this.profile=null;
			return;
		}
	
	
		this.profile=strValue;
	 
	}
	
	/**
	* 品牌简介       
	**/
	public void setProfile(String profile){
		this.profile = profile;
		
		this.setSeted(F.profile);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************公司名称**********************************/	
	/**
	* 公司名称 [非空]      
	**/
	public String getCorporateName(){
		
		if(this.corporateName!=null){
			return this.corporateName;
		}
		
		return this.corporateName;
	}
	/**
	* 获取公司名称格式化(toString)
	**/
	public String getCorporateName$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getCorporateName());
	 
	 	 return strValue;
	}
	/**
	* 根据公司名称反格式化
	**/
	public void setCorporateName$(String strValue){
		if(Utils.empty(strValue)){
			this.corporateName=null;
			return;
		}
	
	
	 	this.corporateName=strValue;
	 
	}
	
	/**
	* 公司名称 [非空]      
	**/
	public void setCorporateName(String corporateName){
		this.corporateName = corporateName;
		
		this.setSeted(F.corporateName);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************公司地址**********************************/	
	/**
	* 公司地址 [非空]      
	**/
	public String getCompanyAddress(){
		
		if(this.companyAddress!=null){
			return this.companyAddress;
		}
		
		return this.companyAddress;
	}
	/**
	* 获取公司地址格式化(toString)
	**/
	public String getCompanyAddress$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getCompanyAddress());
	 
	 	 return strValue;
	}
	/**
	* 根据公司地址反格式化
	**/
	public void setCompanyAddress$(String strValue){
		if(Utils.empty(strValue)){
			this.companyAddress=null;
			return;
		}
	
	
		this.companyAddress=strValue;
	 
	}
	
	/**
	* 公司地址 [非空]      
	**/
	public void setCompanyAddress(String companyAddress){
		this.companyAddress = companyAddress;
		
		this.setSeted(F.companyAddress);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************联系人**********************************/	
	/**
	* 联系人 [非空]      
	**/
	public String getContacts(){
		
		if(this.contacts!=null){
			return this.contacts;
		}
		
		return this.contacts;
	}
	/**
	* 获取联系人格式化(toString)
	**/
	public String getContacts$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getContacts());
	 
	 	 return strValue;
	}
	/**
	* 根据联系人反格式化
	**/
	public void setContacts$(String strValue){
		if(Utils.empty(strValue)){
			this.contacts=null;
			return;
		}
	
	
	 	this.contacts=strValue;
	 
	}
	
	/**
	* 联系人 [非空]      
	**/
	public void setContacts(String contacts){
		this.contacts = contacts;
		
		this.setSeted(F.contacts);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************联系电话**********************************/	
	/**
	* 联系电话 [非空]      
	**/
	public String getContactNumber(){
		
		if(this.contactNumber!=null){
			return this.contactNumber;
		}
		
		return this.contactNumber;
	}
	/**
	* 获取联系电话格式化(toString)
	**/
	public String getContactNumber$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getContactNumber());
	 
	 	 return strValue;
	}
	/**
	* 根据联系电话反格式化
	**/
	public void setContactNumber$(String strValue){
		if(Utils.empty(strValue)){
			this.contactNumber=null;
			return;
		}
	
	
	 	this.contactNumber=strValue;
	 
	}
	
	/**
	* 联系电话 [非空]      
	**/
	public void setContactNumber(String contactNumber){
		this.contactNumber = contactNumber;
		
		this.setSeted(F.contactNumber);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************备注信息**********************************/	
	/**
	* 备注信息       
	**/
	public String getRemark(){
		
		if(this.remark!=null){
			return this.remark;
		}
		
		return this.remark;
	}
	/**
	* 获取备注信息格式化(toString)
	**/
	public String getRemark$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getRemark());
	 
	 	 return strValue;
	}
	/**
	* 根据备注信息反格式化
	**/
	public void setRemark$(String strValue){
		if(Utils.empty(strValue)){
			this.remark=null;
			return;
		}
	
	
		this.remark=strValue;
	 
	}
	
	/**
	* 备注信息       
	**/
	public void setRemark(String remark){
		this.remark = remark;
		
		this.setSeted(F.remark);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************排序**********************************/	
	/**
	* 排序     数值越大越排前  
	**/
	public Integer getmSort(){
		
		if(this.mSort!=null){
			return this.mSort;
		}
		
		return this.mSort;
	}
	/**
	* 获取排序格式化(toString)
	**/
	public String getmSort$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getmSort());
	 
	 	 return strValue;
	}
	/**
	* 根据排序反格式化
	**/
	public void setmSort$(String strValue){
		if(Utils.empty(strValue)){
			this.mSort=null;
			return;
		}
	
	
	 	this.mSort=Utils.parseInteger(strValue);
	 
	}
	
	/**
	* 排序     数值越大越排前  
	**/
	public void setmSort(Integer mSort){
		this.mSort = mSort;
		
		this.setSeted(F.mSort);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************开启状态**********************************/	
	/**
	* 开启状态    1:关闭 2:开启    
	**/
	public Short getOpenState(){
		
		if(this.openState!=null){
			return this.openState;
		}
		
		return this.openState;
	}
	/**
	* 获取开启状态格式化(toString)
	**/
	public String getOpenState$(){
		String strValue="";
	
	
		
			
		 if(Utils.equals(Utils.string(this.getOpenState()),"1"))
			strValue=Utils.string("关闭");		 
			
		 if(Utils.equals(Utils.string(this.getOpenState()),"2"))
			strValue=Utils.string("开启");		 
			
		
	 
	 	 return strValue;
	}
	/**
	* 根据开启状态反格式化
	**/
	public void setOpenState$(String strValue){
		if(Utils.empty(strValue)){
			this.openState=null;
			return;
		}
	
	
		
			
		 if(Utils.equals(strValue,"关闭"))
		 	this.openState=Utils.parseShort("1");
			
		 if(Utils.equals(strValue,"开启"))
		 	this.openState=Utils.parseShort("2");
			
		
	 
	}
	
	/**
	* 开启状态    1:关闭 2:开启    
	**/
	public void setOpenState(Short openState){
		this.openState = openState;
		
		this.setSeted(F.openState);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************修改时间**********************************/	
	/**
	* 修改时间 [非空]      
	**/
	public Date getUpdateTime(){
		
		if(this.updateTime!=null){
			return this.updateTime;
		}
		
		return this.updateTime;
	}
	/**
	* 获取修改时间格式化(toString)
	**/
	public String getUpdateTime$(){
		String strValue="";
	
	
	 	
		 strValue=Utils.string(Utils.date(this.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
		
	 
	 	 return strValue;
	}
	/**
	* 根据修改时间反格式化
	**/
	public void setUpdateTime$(String strValue){
		if(Utils.empty(strValue)){
			this.updateTime=null;
			return;
		}
	
	
	 	this.updateTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	 
	}
	
	/**
	* 修改时间 [非空]      
	**/
	public void setUpdateTime(Date updateTime){
		this.updateTime = updateTime;
		
		this.setSeted(F.updateTime);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************添加时间**********************************/	
	/**
	* 添加时间 [非空]      
	**/
	public Date getAddTime(){
		
		if(this.addTime!=null){
			return this.addTime;
		}
		
		return this.addTime;
	}
	/**
	* 获取添加时间格式化(toString)
	**/
	public String getAddTime$(){
		String strValue="";
	
	
	 	
		 strValue=Utils.string(Utils.date(this.getAddTime(),"yyyy-MM-dd HH:mm:ss"));
		
	 
	 	 return strValue;
	}
	/**
	* 根据添加时间反格式化
	**/
	public void setAddTime$(String strValue){
		if(Utils.empty(strValue)){
			this.addTime=null;
			return;
		}
	
	
	 	this.addTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	 
	}
	
	/**
	* 添加时间 [非空]      
	**/
	public void setAddTime(Date addTime){
		this.addTime = addTime;
		
		this.setSeted(F.addTime);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************状态**********************************/	
	/**
	* 状态 [非空]   1:正常 0:无效    
	**/
	public Short getStatus(){
		
		if(this.status!=null){
			return this.status;
		}
		
		return this.status;
	}
	/**
	* 获取状态格式化(toString)
	**/
	public String getStatus$(){
		String strValue="";
	
	
		
			
		 if(Utils.equals(Utils.string(this.getStatus()),"1"))
			strValue=Utils.string("正常");		 
			
		 if(Utils.equals(Utils.string(this.getStatus()),"0"))
			strValue=Utils.string("无效");		 
			
		
	 
	 	 return strValue;
	}
	/**
	* 根据状态反格式化
	**/
	public void setStatus$(String strValue){
		if(Utils.empty(strValue)){
			this.status=null;
			return;
		}
	
	
		
			
		 if(Utils.equals(strValue,"正常"))
		 	this.status=Utils.parseShort("1");
			
		 if(Utils.equals(strValue,"无效"))
		 	this.status=Utils.parseShort("0");
			
		
	 
	}
	
	/**
	* 状态 [非空]   1:正常 0:无效    
	**/
	public void setStatus(Short status){
		this.status = status;
		
		this.setSeted(F.status);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	/************LAZY3Q_DEFINE_CODE************/	
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(Merchant.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(Merchant.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(Merchant.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(Merchant.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(Merchant.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${Merchant.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${Merchant.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return Merchant.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(Merchant.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${Merchant.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${Merchant.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return Merchant.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(Merchant.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		
		
			
		
		/** 编号 [非空]       **/
		public M id(Object id){if(proxy)return proxy().id(id);  this.put("id", id);return this;};
	 	/** and id is null */
 		public M idNull(){if(proxy)return proxy().idNull();if(this.get("idNot")==null)this.put("idNot", "");this.put("id", null);return this;};
 		/** not .... */
 		public M idNot(){if(proxy)return proxy().idNot();this.put("idNot", "not");return this;};
 		public M idNotNull(){if(proxy)return proxy().idNotNull();this.put("idNot", "not");this.put("id", null);return this;};
 		public M idNot(Object id){if(proxy)return proxy().idNot(id);this.put("idNot", "not");this.put("id", id);return this;};
	 		
		/** and id <= ? */
		public M idMin(Object min){if(proxy)return proxy().idMin(min);this.put("idMin", min);return this;};
		/** and id >= ? */
		public M idMax(Object max){if(proxy)return proxy().idMax(max);this.put("idMax", max);return this;};
			
			
		public M idIn(String ids){
			if(proxy)return proxy().idIn(ids);  this.put("idIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 品牌名称 [非空]       **/
		public M brandName(Object brandName){if(proxy)return proxy().brandName(brandName);  this.put("brandName", brandName);return this;};
	 	/** and brand_name is null */
 		public M brandNameNull(){if(proxy)return proxy().brandNameNull();if(this.get("brandNameNot")==null)this.put("brandNameNot", "");this.put("brandName", null);return this;};
 		/** not .... */
 		public M brandNameNot(){if(proxy)return proxy().brandNameNot();this.put("brandNameNot", "not");return this;};
 		public M brandNameNotNull(){if(proxy)return proxy().brandNameNotNull();this.put("brandNameNot", "not");this.put("brandName", null);return this;};
 		public M brandNameNot(Object brandName){if(proxy)return proxy().brandNameNot(brandName);this.put("brandNameNot", "not");this.put("brandName", brandName);return this;};
	 		
			
		
			
	 	
			
		
		/** 品牌主图 [非空]       **/
		public M banner(Object banner){if(proxy)return proxy().banner(banner);  this.put("banner", banner);return this;};
	 	/** and banner is null */
 		public M bannerNull(){if(proxy)return proxy().bannerNull();if(this.get("bannerNot")==null)this.put("bannerNot", "");this.put("banner", null);return this;};
 		/** not .... */
 		public M bannerNot(){if(proxy)return proxy().bannerNot();this.put("bannerNot", "not");return this;};
 		public M bannerNotNull(){if(proxy)return proxy().bannerNotNull();this.put("bannerNot", "not");this.put("banner", null);return this;};
 		public M bannerNot(Object banner){if(proxy)return proxy().bannerNot(banner);this.put("bannerNot", "not");this.put("banner", banner);return this;};
	 		
			
		
			
	 	
			
		
		/** 品牌简介        **/
		public M profile(Object profile){if(proxy)return proxy().profile(profile);  this.put("profile", profile);return this;};
	 	/** and profile is null */
 		public M profileNull(){if(proxy)return proxy().profileNull();if(this.get("profileNot")==null)this.put("profileNot", "");this.put("profile", null);return this;};
 		/** not .... */
 		public M profileNot(){if(proxy)return proxy().profileNot();this.put("profileNot", "not");return this;};
 		public M profileNotNull(){if(proxy)return proxy().profileNotNull();this.put("profileNot", "not");this.put("profile", null);return this;};
 		public M profileNot(Object profile){if(proxy)return proxy().profileNot(profile);this.put("profileNot", "not");this.put("profile", profile);return this;};
	 		
			
		
			
	 	
			
		
		/** 公司名称 [非空]       **/
		public M corporateName(Object corporateName){if(proxy)return proxy().corporateName(corporateName);  this.put("corporateName", corporateName);return this;};
	 	/** and corporate_name is null */
 		public M corporateNameNull(){if(proxy)return proxy().corporateNameNull();if(this.get("corporateNameNot")==null)this.put("corporateNameNot", "");this.put("corporateName", null);return this;};
 		/** not .... */
 		public M corporateNameNot(){if(proxy)return proxy().corporateNameNot();this.put("corporateNameNot", "not");return this;};
 		public M corporateNameNotNull(){if(proxy)return proxy().corporateNameNotNull();this.put("corporateNameNot", "not");this.put("corporateName", null);return this;};
 		public M corporateNameNot(Object corporateName){if(proxy)return proxy().corporateNameNot(corporateName);this.put("corporateNameNot", "not");this.put("corporateName", corporateName);return this;};
	 		
			
		
			
	 	
			
		
		/** 公司地址 [非空]       **/
		public M companyAddress(Object companyAddress){if(proxy)return proxy().companyAddress(companyAddress);  this.put("companyAddress", companyAddress);return this;};
	 	/** and company_address is null */
 		public M companyAddressNull(){if(proxy)return proxy().companyAddressNull();if(this.get("companyAddressNot")==null)this.put("companyAddressNot", "");this.put("companyAddress", null);return this;};
 		/** not .... */
 		public M companyAddressNot(){if(proxy)return proxy().companyAddressNot();this.put("companyAddressNot", "not");return this;};
 		public M companyAddressNotNull(){if(proxy)return proxy().companyAddressNotNull();this.put("companyAddressNot", "not");this.put("companyAddress", null);return this;};
 		public M companyAddressNot(Object companyAddress){if(proxy)return proxy().companyAddressNot(companyAddress);this.put("companyAddressNot", "not");this.put("companyAddress", companyAddress);return this;};
	 		
			
		
			
	 	
			
		
		/** 联系人 [非空]       **/
		public M contacts(Object contacts){if(proxy)return proxy().contacts(contacts);  this.put("contacts", contacts);return this;};
	 	/** and contacts is null */
 		public M contactsNull(){if(proxy)return proxy().contactsNull();if(this.get("contactsNot")==null)this.put("contactsNot", "");this.put("contacts", null);return this;};
 		/** not .... */
 		public M contactsNot(){if(proxy)return proxy().contactsNot();this.put("contactsNot", "not");return this;};
 		public M contactsNotNull(){if(proxy)return proxy().contactsNotNull();this.put("contactsNot", "not");this.put("contacts", null);return this;};
 		public M contactsNot(Object contacts){if(proxy)return proxy().contactsNot(contacts);this.put("contactsNot", "not");this.put("contacts", contacts);return this;};
	 		
			
		
			
	 	
			
		
		/** 联系电话 [非空]       **/
		public M contactNumber(Object contactNumber){if(proxy)return proxy().contactNumber(contactNumber);  this.put("contactNumber", contactNumber);return this;};
	 	/** and contact_number is null */
 		public M contactNumberNull(){if(proxy)return proxy().contactNumberNull();if(this.get("contactNumberNot")==null)this.put("contactNumberNot", "");this.put("contactNumber", null);return this;};
 		/** not .... */
 		public M contactNumberNot(){if(proxy)return proxy().contactNumberNot();this.put("contactNumberNot", "not");return this;};
 		public M contactNumberNotNull(){if(proxy)return proxy().contactNumberNotNull();this.put("contactNumberNot", "not");this.put("contactNumber", null);return this;};
 		public M contactNumberNot(Object contactNumber){if(proxy)return proxy().contactNumberNot(contactNumber);this.put("contactNumberNot", "not");this.put("contactNumber", contactNumber);return this;};
	 		
			
		
			
	 	
			
		
		/** 备注信息        **/
		public M remark(Object remark){if(proxy)return proxy().remark(remark);  this.put("remark", remark);return this;};
	 	/** and remark is null */
 		public M remarkNull(){if(proxy)return proxy().remarkNull();if(this.get("remarkNot")==null)this.put("remarkNot", "");this.put("remark", null);return this;};
 		/** not .... */
 		public M remarkNot(){if(proxy)return proxy().remarkNot();this.put("remarkNot", "not");return this;};
 		public M remarkNotNull(){if(proxy)return proxy().remarkNotNull();this.put("remarkNot", "not");this.put("remark", null);return this;};
 		public M remarkNot(Object remark){if(proxy)return proxy().remarkNot(remark);this.put("remarkNot", "not");this.put("remark", remark);return this;};
	 		
			
		
			
	 	
			
		
		/** 排序     数值越大越排前   **/
		public M mSort(Object mSort){if(proxy)return proxy().mSort(mSort);  this.put("mSort", mSort);return this;};
	 	/** and m_sort is null */
 		public M mSortNull(){if(proxy)return proxy().mSortNull();if(this.get("mSortNot")==null)this.put("mSortNot", "");this.put("mSort", null);return this;};
 		/** not .... */
 		public M mSortNot(){if(proxy)return proxy().mSortNot();this.put("mSortNot", "not");return this;};
 		public M mSortNotNull(){if(proxy)return proxy().mSortNotNull();this.put("mSortNot", "not");this.put("mSort", null);return this;};
 		public M mSortNot(Object mSort){if(proxy)return proxy().mSortNot(mSort);this.put("mSortNot", "not");this.put("mSort", mSort);return this;};
	 		
		/** and m_sort <= ? */
		public M mSortMin(Object min){if(proxy)return proxy().mSortMin(min);this.put("mSortMin", min);return this;};
		/** and m_sort >= ? */
		public M mSortMax(Object max){if(proxy)return proxy().mSortMax(max);this.put("mSortMax", max);return this;};
			
			
		public M mSortIn(String ids){
			if(proxy)return proxy().mSortIn(ids);  this.put("mSortIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 开启状态    1:关闭 2:开启     **/
		public M openState(Object openState){if(proxy)return proxy().openState(openState);  this.put("openState", openState);return this;};
	 	/** and open_state is null */
 		public M openStateNull(){if(proxy)return proxy().openStateNull();if(this.get("openStateNot")==null)this.put("openStateNot", "");this.put("openState", null);return this;};
 		/** not .... */
 		public M openStateNot(){if(proxy)return proxy().openStateNot();this.put("openStateNot", "not");return this;};
 		public M openStateNotNull(){if(proxy)return proxy().openStateNotNull();this.put("openStateNot", "not");this.put("openState", null);return this;};
 		public M openStateNot(Object openState){if(proxy)return proxy().openStateNot(openState);this.put("openStateNot", "not");this.put("openState", openState);return this;};
	 		
			
		public M openStateIn(String ids){
			if(proxy)return proxy().openStateIn(ids);  this.put("openStateIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 修改时间 [非空]       **/
		public M updateTime(Object updateTime){if(proxy)return proxy().updateTime(updateTime);  this.put("updateTime", updateTime);return this;};
	 	/** and update_time is null */
 		public M updateTimeNull(){if(proxy)return proxy().updateTimeNull();if(this.get("updateTimeNot")==null)this.put("updateTimeNot", "");this.put("updateTime", null);return this;};
 		/** not .... */
 		public M updateTimeNot(){if(proxy)return proxy().updateTimeNot();this.put("updateTimeNot", "not");return this;};
 		public M updateTimeNotNull(){if(proxy)return proxy().updateTimeNotNull();this.put("updateTimeNot", "not");this.put("updateTime", null);return this;};
 		public M updateTimeNot(Object updateTime){if(proxy)return proxy().updateTimeNot(updateTime);this.put("updateTimeNot", "not");this.put("updateTime", updateTime);return this;};
	 		
 		/** and update_time >= ? */
 		public M updateTimeStart(Object start){if(proxy)return proxy().updateTimeStart(start);this.put("updateTimeStart", start);return this;};			
 		/** and update_time <= ? */
 		public M updateTimeEnd(Object end){if(proxy)return proxy().updateTimeEnd(end);this.put("updateTimeEnd", end);return this;};
			
			
		
			
	 	
			
		
		/** 添加时间 [非空]       **/
		public M addTime(Object addTime){if(proxy)return proxy().addTime(addTime);  this.put("addTime", addTime);return this;};
	 	/** and add_time is null */
 		public M addTimeNull(){if(proxy)return proxy().addTimeNull();if(this.get("addTimeNot")==null)this.put("addTimeNot", "");this.put("addTime", null);return this;};
 		/** not .... */
 		public M addTimeNot(){if(proxy)return proxy().addTimeNot();this.put("addTimeNot", "not");return this;};
 		public M addTimeNotNull(){if(proxy)return proxy().addTimeNotNull();this.put("addTimeNot", "not");this.put("addTime", null);return this;};
 		public M addTimeNot(Object addTime){if(proxy)return proxy().addTimeNot(addTime);this.put("addTimeNot", "not");this.put("addTime", addTime);return this;};
	 		
 		/** and add_time >= ? */
 		public M addTimeStart(Object start){if(proxy)return proxy().addTimeStart(start);this.put("addTimeStart", start);return this;};			
 		/** and add_time <= ? */
 		public M addTimeEnd(Object end){if(proxy)return proxy().addTimeEnd(end);this.put("addTimeEnd", end);return this;};
			
			
		
			
	 	
			
		
		/** 状态 [非空]   1:正常 0:无效     **/
		public M status(Object status){if(proxy)return proxy().status(status);  this.put("status", status);return this;};
	 	/** and status is null */
 		public M statusNull(){if(proxy)return proxy().statusNull();if(this.get("statusNot")==null)this.put("statusNot", "");this.put("status", null);return this;};
 		/** not .... */
 		public M statusNot(){if(proxy)return proxy().statusNot();this.put("statusNot", "not");return this;};
 		public M statusNotNull(){if(proxy)return proxy().statusNotNull();this.put("statusNot", "not");this.put("status", null);return this;};
 		public M statusNot(Object status){if(proxy)return proxy().statusNot(status);this.put("statusNot", "not");this.put("status", status);return this;};
	 		
			
		public M statusIn(String ids){
			if(proxy)return proxy().statusIn(ids);  this.put("statusIn", ids);return this;
		};	
 			
		
			
	 	
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	
	 	/** 获取所有品牌信息 **/
		public @api List<Merchant> list(Integer size){			
			return getMerchantList(this,size);
		}
		/** 获取品牌信息分页 **/
		public @api Page<Merchant> page(Integer page,Integer size){			
			return getMerchantPage(page, size , this);
		}
		/** 根据查询条件取品牌信息 **/
		public @api Merchant get(){			
			return getMerchant(this);
		}
		/** 获取品牌信息数 **/
		public @api Long count(){			
			return getMerchantCount(this);
		}
		/** 获取品牌信息表达式 **/
		public @api <T> T eval(String strEval){			
			return getMerchantEval(strEval,this);
		}
		
		/** 获取品牌信息统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getMerchantStats(this,sumKey,groupKey,dateType);
		}
		/** 获取品牌信息统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getMerchantStats(this,sumKey,groupKey,-1);
		}
		
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateMerchant(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteMerchant(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		
			
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String id="id";
	 			
			
	 	
			
		/** 品牌名称 [非空]       **/
		public final static @type(String.class)  String brandName="brandName";
	 			
			
	 	
			
		/** 品牌主图 [非空]       **/
		public final static @type(String.class)  String banner="banner";
	 			
			
	 	
			
		/** 品牌简介        **/
		public final static @type(String.class) @like String profile="profile";
	 			
			
	 	
			
		/** 公司名称 [非空]       **/
		public final static @type(String.class)  String corporateName="corporateName";
	 			
			
	 	
			
		/** 公司地址 [非空]       **/
		public final static @type(String.class) @like String companyAddress="companyAddress";
	 			
			
	 	
			
		/** 联系人 [非空]       **/
		public final static @type(String.class)  String contacts="contacts";
	 			
			
	 	
			
		/** 联系电话 [非空]       **/
		public final static @type(String.class)  String contactNumber="contactNumber";
	 			
			
	 	
			
		/** 备注信息        **/
		public final static @type(String.class) @like String remark="remark";
	 			
			
	 	
			
		/** 排序     数值越大越排前   **/
		public final static @type(Integer.class)  String mSort="mSort";
	 			
		/** and m_sort >= ? */
		public final static @type(Integer.class) String mSortMin="mSortMin";
		/** and m_sort <= ? */
		public final static @type(Integer.class) String mSortMax="mSortMax";
				
			
	 	
			
		/** 开启状态    1:关闭 2:开启     **/
		public final static @type(Short.class)  String openState="openState";
	 			
			
	 	
			
		/** 修改时间 [非空]       **/
		public final static @type(Date.class)  String updateTime="updateTime";
	 			
	 	/** and update_time >= ? */
 		public final static @type(Date.class) String updateTimeStart="updateTimeStart";
 		/** and update_time <= ? */
 		public final static @type(Date.class) String updateTimeEnd="updateTimeEnd";
				
			
	 	
			
		/** 添加时间 [非空]       **/
		public final static @type(Date.class)  String addTime="addTime";
	 			
	 	/** and add_time >= ? */
 		public final static @type(Date.class) String addTimeStart="addTimeStart";
 		/** and add_time <= ? */
 		public final static @type(Date.class) String addTimeEnd="addTimeEnd";
				
			
	 	
			
		/** 状态 [非空]   1:正常 0:无效     **/
		public final static @type(Short.class)  String status="status";
	 			
			
	 	
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/** 对象的数据库字段描述 **/
	public static enum C{
		
		id("id"),
		brandName("brand_name"),
		banner("banner"),
		profile("profile"),
		corporateName("corporate_name"),
		companyAddress("company_address"),
		contacts("contacts"),
		contactNumber("contact_number"),
		remark("remark"),
		mSort("m_sort"),
		openState("open_state"),
		updateTime("update_time"),
		addTime("add_time"),
		status("status"),
		count("count");
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	
	/**
	* 获取品牌信息数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = Merchant.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = Merchant.getMerchant(params);
			else
				value = Merchant.getMerchantList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  Merchant.where().id(param).get();
		else if(!Utils.empty(param.toString()))
			value = Merchant.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		return toJSON(simple,0);
	}
	public Map toJSON(boolean simple,int step){
		Map map = new HashMap();
		map.put("id",this.getId());
	
		Utils.fms(map,simple?"":"id",this.getId(),this.getId$());
		
			
 		
	
		Utils.fms(map,simple?"name":"brandName",this.getBrandName(),this.getBrandName$());
		
			
 		
	
		Utils.fms(map,simple?"":"banner",this.getBanner(),this.getBanner$());
		
			
 		
	
		Utils.fms(map,simple?"":"profile",this.getProfile(),this.getProfile$());
		
			
 		
	
		Utils.fms(map,simple?"name":"corporateName",this.getCorporateName(),this.getCorporateName$());
		
			
 		
	
		Utils.fms(map,simple?"address":"companyAddress",this.getCompanyAddress(),this.getCompanyAddress$());
		
			
 		
	
		Utils.fms(map,simple?"":"contacts",this.getContacts(),this.getContacts$());
		
			
 		
	
		Utils.fms(map,simple?"number":"contactNumber",this.getContactNumber(),this.getContactNumber$());
		
			
 		
	
		Utils.fms(map,simple?"":"remark",this.getRemark(),this.getRemark$());
		
			
 		
	
		Utils.fms(map,simple?"sort":"mSort",this.getmSort(),this.getmSort$());
		
			
 		
	
		Utils.fms(map,simple?"state":"openState",this.getOpenState(),this.getOpenState$());
		
			
 		
	
		Utils.fms(map,simple?"time":"updateTime",this.getUpdateTime(),this.getUpdateTime$());
		
			
 		
	
		Utils.fms(map,simple?"time":"addTime",this.getAddTime(),this.getAddTime$());
		
			
 		
	
		Utils.fms(map,simple?"":"status",this.getStatus(),this.getStatus$());
		
			
 		
	
		if(this.suffix!=null)map.put("suffix", this.suffix);
		
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
	
		map.put("id",this.getId());
 		
	
		map.put("brandName",this.getBrandName());
 		
	
		map.put("banner",this.getBanner());
 		
	
		map.put("profile",this.getProfile());
 		
	
		map.put("corporateName",this.getCorporateName());
 		
	
		map.put("companyAddress",this.getCompanyAddress());
 		
	
		map.put("contacts",this.getContacts());
 		
	
		map.put("contactNumber",this.getContactNumber());
 		
	
		map.put("remark",this.getRemark());
 		
	
		map.put("mSort",this.getmSort());
 		
	
		map.put("openState",this.getOpenState());
 		
	
		map.put("updateTime",this.getUpdateTime());
 		
	
		map.put("addTime",this.getAddTime());
 		
	
		map.put("status",this.getStatus());
 		
	
		map.put("suffix", this.suffix);
		
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static Merchant fromMap(Map map){
		Merchant merchant = new Merchant();
	
		merchant.id = Utils.parseLong(map.get("id"));
 		
	
		merchant.brandName = Utils.parseString(map.get("brandName"));
 		
	
		merchant.banner = Utils.parseString(map.get("banner"));
 		
	
		merchant.profile = Utils.parseString(map.get("profile"));
 		
	
		merchant.corporateName = Utils.parseString(map.get("corporateName"));
 		
	
		merchant.companyAddress = Utils.parseString(map.get("companyAddress"));
 		
	
		merchant.contacts = Utils.parseString(map.get("contacts"));
 		
	
		merchant.contactNumber = Utils.parseString(map.get("contactNumber"));
 		
	
		merchant.remark = Utils.parseString(map.get("remark"));
 		
	
		merchant.mSort = Utils.parseInteger(map.get("mSort"));
 		
	
		merchant.openState = Utils.parseShort(map.get("openState"));
 		
	
		merchant.updateTime = Utils.parseDate(map.get("updateTime"));
 		
	
		merchant.addTime = Utils.parseDate(map.get("addTime"));
 		
	
		merchant.status = Utils.parseShort(map.get("status"));
 		
	
		return merchant;
	}
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(Merchant old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	
	
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	
	public static String getIcon(){
		return "/images/icons/1938404416.png";
	}
	public static String getIconfont(){
		return "icon-nan";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,Merchant.M params){
		if(params==null)params=new Merchant.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/business/merchant.edit.html?";
		if(params.get("id")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("id"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/business/merchant.html?1=1";
		
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		
		
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.id(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(Merchant.ACT act,Merchant.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",Merchant.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(Merchant.ACT act,Merchant.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",Merchant.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.IMerchantDao getMerchantDao(){
		return Utils.getBean("merchantDao");
	};
	
}